package com.frxuexi.user.viewmodel

import com.frxuexi.lib_base.BaseEntity
import com.frxuexi.lib_base.BaseViewModel
import com.frxuexi.lib_base.HttpType
import com.frxuexi.user.intent.UserIntent
import com.frxuexi.user.repository.UserNetRepo
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

@HiltViewModel
class UserNetViewModel @Inject constructor(private val userNetRepo: UserNetRepo):BaseViewModel<UserIntent> (){
    override fun handleIntent(it: UserIntent) {
        when(it){
            is UserIntent.addEmployee->{
                httpRequest2(userNetRepo.addEmployee(it.map))
            }
            is UserIntent.loginNet->{
                httpRequest2(userNetRepo.login(it.map) as Flow<BaseEntity<Any>>)
            }
            is UserIntent.addApprove->{
                httpRequest2(userNetRepo.addApprove(it.map))
            }
            is UserIntent.getApprs->{
                httpRequest2(userNetRepo.getApprs(it.status) as Flow<BaseEntity<Any>>)
            }
            is UserIntent.approve->{
                httpRequest2((userNetRepo.approve(it.map)))
            }

            else -> {}
        }
    }
}